package com.lee.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.lee.config.LeeConfig;


/**
 * 通用配置
 * 
 * @author LiPengFei
 *
 */
@Configuration
public class ResourcesConfig implements WebMvcConfigurer {
	/**
	 * 首页地址
	 */
	@Value("${shiro.user.indexUrl}")
	private String indexUrl;

	/**
	 * 默认首页的设置，当输入域名是可以自动跳转到默认指定的网页
	 */
	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
		registry.addViewController("/").setViewName("forward:" + indexUrl);
	}
	
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /** 头像上传虚拟路径 */
        registry.addResourceHandler("/profile/**").addResourceLocations("file:" + LeeConfig.getProfile());
    }
}